package com.minimalist.common.feign.client.lindi;

import com.minimalist.common.config.mybatis.bo.PageResp;
import com.minimalist.common.entity.lindi.vo.contracttemplate.LindiContractTemplateVO;
import com.minimalist.common.entity.lindi.vo.tradeapplicationcontract.LindiTradeApplicationContractQueryVO;
import com.minimalist.common.entity.lindi.vo.tradeapplicationcontract.LindiTradeApplicationContractVO;
import com.minimalist.common.feign.config.FeignConfig;
import com.minimalist.common.feign.fallback.lindi.LindiTradeApplicationContractFeignClientFallbackFactory;
import com.minimalist.common.response.R;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 林地指标交易平台_交易申请合同 Feign 客户端
 *
 * @author 11987
 */
@FeignClient(name = "minimalist-lindi"
        , contextId = "lindiTradeApplicationContractFeignClient"
        , path = "/minimalist/lindi/tradeApplicationContract"
        , configuration = FeignConfig.class
        , fallbackFactory = LindiTradeApplicationContractFeignClientFallbackFactory.class)
public interface LindiTradeApplicationContractFeignClient{

    /**
     * 添加交易申请合同
     *
     * @param tradeApplicationContractVO 交易申请合同信息
     * @return 成功或失败
     */
    @PostMapping("/addTradeApplicationContract")
    @Operation(summary = "添加交易申请合同")
    R<?> addTradeApplicationContract(
            @RequestBody @Validated(Add.class)
            LindiTradeApplicationContractVO tradeApplicationContractVO);

    /**
     * 删除交易申请合同 -> 根据交易申请合同ID删除
     *
     * @param tradeApplicationContractId 交易申请合同ID
     * @return 成功或失败
     */
    @DeleteMapping("/deleteTradeApplicationContractByTradeApplicationContractId")
    @Operation(summary = "删除交易申请合同 -> 根据交易申请合同ID删除")
    R<?> deleteTradeApplicationContractByTradeApplicationContractId(
            @RequestParam("tradeApplicationContractId")
            @NotNull(message = "交易申请合同ID不能为空")
            @Parameter(name = "tradeApplicationContractId", required = true, description = "交易申请合同ID")
            Long tradeApplicationContractId);

    /**
     * 修改交易申请合同
     *
     * @param tradeApplicationContractVO 交易申请合同信息
     * @return 成功或失败
     */
    @PutMapping("/updateTradeApplicationContractByTradeApplicationContractId")
    @Operation(summary = "修改交易申请合同")
    R<?> updateTradeApplicationContractByTradeApplicationContractId(
            @RequestBody @Validated(Update.class)
            LindiTradeApplicationContractVO tradeApplicationContractVO);

    /**
     * 查询交易申请合同列表(分页)
     *
     * @param queryVO 查询条件
     * @return 交易申请合同列表
     */
    @GetMapping("/getPageTradeApplicationContractList")
    @Operation(summary = "查询交易申请合同列表(分页)")
    R<PageResp<LindiTradeApplicationContractVO>> getPageTradeApplicationContractList(
            @RequestBody LindiTradeApplicationContractQueryVO queryVO);

    /**
     * 根据交易申请合同ID查询交易申请合同
     *
     * @param tradeApplicationContractId 交易申请合同ID
     * @return 交易申请合同
     */
    @GetMapping("/getTradeApplicationContractByTradeApplicationContractId/{tradeApplicationContractId}")
    @Operation(summary = "根据交易申请合同ID查询交易申请合同")
    R<LindiTradeApplicationContractVO> getTradeApplicationContractByTradeApplicationContractId(
            @PathVariable(value = "tradeApplicationContractId")
            @NotNull(message = "交易申请合同ID不能为空")
            @Parameter(name = "tradeApplicationContractId", description = "交易申请合同ID", required = true)
            Long tradeApplicationContractId);

    /**
     * 根据交易申请ID查询合同信息
     *
     * @param tradeApplicationId 交易申请ID
     * @return 合同信息
     */
    @GetMapping("/getTradeApplicationContractByTradeApplicationId/{tradeApplicationId}")
    @Operation(summary = "根据交易申请ID查询合同信息")
    R<LindiTradeApplicationContractVO> getTradeApplicationContractByTradeApplicationId(
            @PathVariable(value = "tradeApplicationId")
            @NotNull(message = "交易申请ID不能为空")
            @Parameter(name = "tradeApplicationId", description = "交易申请ID", required = true)
            Long tradeApplicationId);

    /**
     * 根据交易申请ID查询交易申请合同列表
     *
     * @param tradeApplicationId 交易申请ID
     * @return 交易申请合同列表
     */
    @GetMapping("/getTradeApplicationContractListByTradeApplicationId/{tradeApplicationId}")
    @Operation(summary = "根据交易申请ID查询交易申请合同列表")
    R<List<LindiTradeApplicationContractVO>> getTradeApplicationContractListByTradeApplicationId(
            @PathVariable(value = "tradeApplicationId")
            @NotNull(message = "交易申请ID不能为空")
            @Parameter(name = "tradeApplicationId", description = "交易申请ID", required = true)
            Long tradeApplicationId);

    /**
     * 获取合同模板列表
     *
     * @return R
     */
    @GetMapping("/getContractTemplateList")
    @Operation(summary = "获取合同模板列表")
    R<List<LindiContractTemplateVO>> getContractTemplateList();

    /**
     * 生成合同
     *
     * @param tradeApplicationId 交易申请ID
     * @param contractTemplateId 合同模板ID
     * @param createId           创建人ID
     * @param tenantId           租户ID
     * @return 合同信息
     */
    @PostMapping("/generateContract")
    @Operation(summary = "生成合同")
    R<LindiTradeApplicationContractVO> generateContract(
            @RequestParam("tradeApplicationId")
            @NotNull(message = "交易申请ID不能为空")
            @Parameter(name = "tradeApplicationId", required = true, description = "交易申请ID")
            Long tradeApplicationId,
            @RequestParam("contractTemplateId")
            @NotNull(message = "合同模板ID不能为空")
            @Parameter(name = "contractTemplateId", required = true, description = "合同模板ID")
            Long contractTemplateId,
            @RequestParam("createId") Long createId,
            @RequestParam("tenantId") Long tenantId);
}